local thbattle__cuixiang_jiuhao = fk.CreateSkill {

  name = "thbattle__cuixiang_jiuhao",

  tags = {  },

}



thbattle__cuixiang_jiuhao:addEffect("active", {
  prompt = "#thbattle__cuixiang_jiuhao",
  anim_type = "offensive",
  target_num = 1,
  target_filter =function (self, player, to_select, selected, selected_cards, card, extra_data)
        return #selected < 1 and to_select ~= player and not to_select:isKongcheng()
        and to_select:getMark("thbattle__cuixiang_jiuhao-phase") == 0
  end,
  can_use = function(self, player, card, extra_data)
    return player:getMark("thbattle__cuixiang_jiuhao-turn") == 0 and not player:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local pindian_struct = player:pindian({ target }, thbattle__cuixiang_jiuhao.name)
    if pindian_struct.results[target].winner == player then
      room:useCard({
        from = player,
        tos = {  player  },
        card = Fk:cloneCard("jiu"),
      })
      room:useCard({
        from = target,
        tos = {  target },
        card = Fk:cloneCard("jiu"),
      })
    else
      room:addPlayerMark(player, "thbattle__cuixiang_jiuhao-turn")
    end
    room:addPlayerMark(target, "thbattle__cuixiang_jiuhao-phase")
  end,
})

return thbattle__cuixiang_jiuhao